package nuce.form;

import java.util.Random;
import javax.swing.JOptionPane;
import nuce.bo.QuestionBO;
import nuce.bo.QuestionSet;
import nuce.entity.Question;

public class InterfaceForm extends javax.swing.JFrame {

    /** Creates new form InterfaceForm */
    public InterfaceForm() {
        initComponents();
        initExtend();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        btngrpQuestion = new javax.swing.ButtonGroup();
        jPanel1 = new javax.swing.JPanel();
        lbl1 = new javax.swing.JLabel();
        lbl2 = new javax.swing.JLabel();
        lbl3 = new javax.swing.JLabel();
        lbl4 = new javax.swing.JLabel();
        lbl5 = new javax.swing.JLabel();
        lbl6 = new javax.swing.JLabel();
        lbl7 = new javax.swing.JLabel();
        lbl8 = new javax.swing.JLabel();
        lbl9 = new javax.swing.JLabel();
        lbl10 = new javax.swing.JLabel();
        lbl11 = new javax.swing.JLabel();
        lbl12 = new javax.swing.JLabel();
        lbl13 = new javax.swing.JLabel();
        lbl14 = new javax.swing.JLabel();
        lbl15 = new javax.swing.JLabel();
        lblHalf = new javax.swing.JButton();
        lblCall = new javax.swing.JButton();
        btnUser = new javax.swing.JButton();
        jPanel2 = new javax.swing.JPanel();
        jPanel5 = new javax.swing.JPanel();
        lblPlayerName = new javax.swing.JLabel();
        jPanel3 = new javax.swing.JPanel();
        jPanel4 = new javax.swing.JPanel();
        lblQuestion = new javax.swing.JLabel();
        rdbtnA = new javax.swing.JRadioButton();
        rdbtnB = new javax.swing.JRadioButton();
        rdbtnC = new javax.swing.JRadioButton();
        rdbtnD = new javax.swing.JRadioButton();
        btnNext = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setResizable(false);

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        lbl1.setFont(new java.awt.Font("Tahoma", 1, 12));
        lbl1.setForeground(new java.awt.Color(0, 51, 204));
        lbl1.setText("1  * 100");

        lbl2.setFont(new java.awt.Font("Tahoma", 1, 12));
        lbl2.setForeground(new java.awt.Color(0, 51, 204));
        lbl2.setText("2  * 200");

        lbl3.setFont(new java.awt.Font("Tahoma", 1, 12));
        lbl3.setForeground(new java.awt.Color(0, 51, 204));
        lbl3.setText("3  * 300");

        lbl4.setFont(new java.awt.Font("Tahoma", 1, 12));
        lbl4.setForeground(new java.awt.Color(0, 51, 204));
        lbl4.setText("4  * 400");

        lbl5.setFont(new java.awt.Font("Tahoma", 1, 12));
        lbl5.setForeground(new java.awt.Color(255, 102, 102));
        lbl5.setText("5   * 1.000");

        lbl6.setFont(new java.awt.Font("Tahoma", 1, 12));
        lbl6.setForeground(new java.awt.Color(0, 51, 204));
        lbl6.setText("6   * 2.000");

        lbl7.setFont(new java.awt.Font("Tahoma", 1, 12));
        lbl7.setForeground(new java.awt.Color(0, 51, 204));
        lbl7.setText("7   * 3.000");

        lbl8.setFont(new java.awt.Font("Tahoma", 1, 12));
        lbl8.setForeground(new java.awt.Color(0, 51, 204));
        lbl8.setText("8   * 6.000");

        lbl9.setFont(new java.awt.Font("Tahoma", 1, 12));
        lbl9.setForeground(new java.awt.Color(0, 51, 204));
        lbl9.setText("9   * 9.000");

        lbl10.setFont(new java.awt.Font("Tahoma", 1, 12));
        lbl10.setForeground(new java.awt.Color(255, 102, 102));
        lbl10.setText("10 * 15.000");

        lbl11.setFont(new java.awt.Font("Tahoma", 1, 12));
        lbl11.setForeground(new java.awt.Color(0, 51, 204));
        lbl11.setText("11 * 25.000");

        lbl12.setFont(new java.awt.Font("Tahoma", 1, 12));
        lbl12.setForeground(new java.awt.Color(0, 51, 204));
        lbl12.setText("12 * 35.000");

        lbl13.setFont(new java.awt.Font("Tahoma", 1, 12));
        lbl13.setForeground(new java.awt.Color(0, 51, 204));
        lbl13.setText("13 * 50.000");

        lbl14.setFont(new java.awt.Font("Tahoma", 1, 12));
        lbl14.setForeground(new java.awt.Color(0, 51, 204));
        lbl14.setText("14 * 95.000");

        lbl15.setFont(new java.awt.Font("Tahoma", 1, 12));
        lbl15.setForeground(new java.awt.Color(255, 102, 102));
        lbl15.setText("15 * 120.000");

        lblHalf.setText("50/50");
        lblHalf.setMargin(new java.awt.Insets(2, 8, 2, 8));
        lblHalf.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                lblHalfActionPerformed(evt);
            }
        });

        lblCall.setText("Call");
        lblCall.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                lblCallActionPerformed(evt);
            }
        });

        btnUser.setText("User");
        btnUser.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnUserActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(lblHalf, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(lblCall, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnUser, javax.swing.GroupLayout.DEFAULT_SIZE, 57, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addGap(26, 26, 26)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lbl1, javax.swing.GroupLayout.DEFAULT_SIZE, 179, Short.MAX_VALUE)
                            .addComponent(lbl2, javax.swing.GroupLayout.DEFAULT_SIZE, 179, Short.MAX_VALUE)
                            .addComponent(lbl3, javax.swing.GroupLayout.DEFAULT_SIZE, 179, Short.MAX_VALUE)
                            .addComponent(lbl11, javax.swing.GroupLayout.DEFAULT_SIZE, 179, Short.MAX_VALUE)
                            .addComponent(lbl12, javax.swing.GroupLayout.DEFAULT_SIZE, 179, Short.MAX_VALUE)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(lbl9, javax.swing.GroupLayout.DEFAULT_SIZE, 173, Short.MAX_VALUE)
                                .addGap(6, 6, 6))
                            .addComponent(lbl10, javax.swing.GroupLayout.DEFAULT_SIZE, 179, Short.MAX_VALUE)
                            .addComponent(lbl15, javax.swing.GroupLayout.DEFAULT_SIZE, 179, Short.MAX_VALUE)
                            .addComponent(lbl13, javax.swing.GroupLayout.DEFAULT_SIZE, 179, Short.MAX_VALUE)
                            .addComponent(lbl14, javax.swing.GroupLayout.DEFAULT_SIZE, 179, Short.MAX_VALUE)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(lbl5, javax.swing.GroupLayout.DEFAULT_SIZE, 173, Short.MAX_VALUE)
                                .addGap(6, 6, 6))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(lbl6, javax.swing.GroupLayout.DEFAULT_SIZE, 173, Short.MAX_VALUE)
                                .addGap(6, 6, 6))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(lbl8, javax.swing.GroupLayout.DEFAULT_SIZE, 173, Short.MAX_VALUE)
                                .addGap(6, 6, 6))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(lbl7, javax.swing.GroupLayout.DEFAULT_SIZE, 173, Short.MAX_VALUE)
                                .addGap(6, 6, 6))
                            .addComponent(lbl4, javax.swing.GroupLayout.DEFAULT_SIZE, 179, Short.MAX_VALUE))))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(29, 29, 29)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblHalf)
                    .addComponent(btnUser)
                    .addComponent(lblCall))
                .addGap(33, 33, 33)
                .addComponent(lbl15, javax.swing.GroupLayout.DEFAULT_SIZE, 18, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lbl14, javax.swing.GroupLayout.DEFAULT_SIZE, 18, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lbl13, javax.swing.GroupLayout.DEFAULT_SIZE, 18, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lbl12, javax.swing.GroupLayout.DEFAULT_SIZE, 18, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lbl11, javax.swing.GroupLayout.DEFAULT_SIZE, 18, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lbl10, javax.swing.GroupLayout.DEFAULT_SIZE, 18, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lbl9, javax.swing.GroupLayout.DEFAULT_SIZE, 18, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lbl8, javax.swing.GroupLayout.DEFAULT_SIZE, 18, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lbl7, javax.swing.GroupLayout.DEFAULT_SIZE, 18, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lbl6, javax.swing.GroupLayout.DEFAULT_SIZE, 18, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lbl5, javax.swing.GroupLayout.DEFAULT_SIZE, 18, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lbl4, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lbl3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lbl2, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lbl1)
                .addGap(54, 54, 54))
        );

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder("Thong tin nguoi choi"));

        lblPlayerName.setText("Nguyen Chi Linh");

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lblPlayerName, javax.swing.GroupLayout.DEFAULT_SIZE, 188, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(lblPlayerName, javax.swing.GroupLayout.DEFAULT_SIZE, 28, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(323, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(19, 19, 19)
                .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(200, Short.MAX_VALUE))
        );

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder("Cau hoi"));

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lblQuestion, javax.swing.GroupLayout.DEFAULT_SIZE, 511, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(lblQuestion, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 46, Short.MAX_VALUE)
        );

        rdbtnA.setText("A:");

        rdbtnB.setText("B:");

        rdbtnC.setText("C:");

        rdbtnD.setText("D:");

        btnNext.setText("Ok");
        btnNext.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnNextActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(rdbtnC, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(rdbtnA, javax.swing.GroupLayout.DEFAULT_SIZE, 257, Short.MAX_VALUE))
                                .addGap(18, 18, 18)
                                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(rdbtnD, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(rdbtnB, javax.swing.GroupLayout.DEFAULT_SIZE, 251, Short.MAX_VALUE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 17, Short.MAX_VALUE))
                            .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addContainerGap())
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                        .addComponent(btnNext)
                        .addGap(249, 249, 249))))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(rdbtnA)
                    .addComponent(rdbtnB))
                .addGap(18, 18, 18)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(rdbtnC)
                    .addComponent(rdbtnD))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 30, Short.MAX_VALUE)
                .addComponent(btnNext))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    public void initExtend() {
        btngrpQuestion.add(rdbtnA);
        btngrpQuestion.add(rdbtnB);
        btngrpQuestion.add(rdbtnC);
        btngrpQuestion.add(rdbtnD);
        createQuestion();
    }

    public boolean isAnwer(int i) //lam chuc nang kiem tra
    {
        // dang lam do dang muc nay
        //kiem tra xem o cau hoi thu i tra loi dung hay sai dua vao ban tham chieu cau hoi
        return false;
    }

    //Chuyen qua cau hoi tiep theo
    private void btnNextActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNextActionPerformed
        if (countQuestion < q.getCount()) {
//            lblQuestion.setText(q.getItem(countQuestion).getContent());
//            lblA.setText(q.getItem(countQuestion).getAnswer1());
//            lblB.setText(q.getItem(countQuestion).getAnswer2());
//            lblC.setText(q.getItem(countQuestion).getAnswer3());
//            lblD.setText(q.getItem(countQuestion).getAnswer4());
            lblQuestion.setText(q.getItem(countQuestion).getContent());
            rdbtnA.setText("A: " + q.getItem(countQuestion).getAnswer1());
            rdbtnB.setText("B: " + q.getItem(countQuestion).getAnswer2());
            rdbtnC.setText("C: " + q.getItem(countQuestion).getAnswer3());
            rdbtnD.setText("D: " + q.getItem(countQuestion).getAnswer4());
            countQuestion++;
        }
    }//GEN-LAST:event_btnNextActionPerformed

    // Su tro giup 50/50 =============================================================
    private void lblHalfActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_lblHalfActionPerformed
        // TODO add your handling code here:
        //if ( ko phai la cau tra loi dung thi bo di phuong an sai)
        JOptionPane.showMessageDialog(null, "Dang lam chuc nang nay");
    }//GEN-LAST:event_lblHalfActionPerformed
    //Tro giup goi dien thoai cho nguoi than ============================================
    private void lblCallActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_lblCallActionPerformed
        // TODO add your handling code here:
        JOptionPane.showMessageDialog(null, "dang lam chuc nang Goi dien thoai cho nguoi than nay");
    }//GEN-LAST:event_lblCallActionPerformed

    //Hoi y kien khan gia trong truong quay:
    private void btnUserActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnUserActionPerformed
        // TODO add your handling code here:
        
        JOptionPane.showMessageDialog(null, "Dang lam chuc nang Hoi y kien khan gia trong truong quay");
    }//GEN-LAST:event_btnUserActionPerformed

    //Tao cau bo gom 15 hoi random lay tu thu vien cau hoi
    public void createQuestion() {
        q = new QuestionSet();
        countQuestion = 0;
        q1 = new QuestionSet();
        q2 = new QuestionSet();
        q3 = new QuestionSet();
        q1.SelectByLevel(1);
        q2.SelectByLevel(2);
        q3.SelectByLevel(3);
// Do du lieu vao q (15 cau hoi )
        int i = 0;
        int indextRandom;
        for (i = 0; i < 5; i++) {
            if (q1.getCount() > 0) {
                Random rd = new Random(q1.getCount());
                indextRandom = rd.nextInt(q1.getCount());
                q.add(q1.getItem(indextRandom));
                q1.remove(indextRandom);
            } else {
                q.add(q1.getItem(0));
            }
        }
        for (i = 0; i < 5; i++) {
            if (q2.getCount() > 0) {
                Random rd = new Random(q2.getCount());
                indextRandom = rd.nextInt(q2.getCount());
                q.add(q2.getItem(indextRandom));
                q2.remove(indextRandom);
            } else {
                q.add(q2.getItem(0));
            }
        }
        for (i = 0; i < 5; i++) {
            if (q3.getCount() > 0) {
                Random rd = new Random(q3.getCount());
                indextRandom = rd.nextInt(q3.getCount());
                q.add(q3.getItem(indextRandom));
                q3.remove(indextRandom);
            } else {
                q.add(q2.getItem(0));
            }
        }
        //randomAnwer();
    }

    public void randomAnwer() {
        int i, indexRandom=1;
        int n = q.getCount();
        Random rd = new Random(4);
        indexRandom = rd.nextInt(4)+1;
        AnsTrue = new int[n];
        QuestionBO qb = new QuestionBO();
        Question qtemp = new Question();
                
        for (i=0; i<n; i++){
            qtemp = q.getItem(i);
            qb.swap(qtemp, 1, indexRandom);
            q.updateItem(i,qtemp);
            AnsTrue[i] = indexRandom;
        }
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new InterfaceForm().setVisible(true);
            }
        });

    }
    //Nguyen chi linh data them vao:
    private int countQuestion = 0;
    private QuestionSet q; //tap cau hoi gom 15 cau : 5 cau level 1, 5 cau level 2  va` 5 cau level 3
    private int[] AnsTrue; // vi tri cua cau hoi dung chua set gia tri; hom sau set gia tri cho no'
    private QuestionSet q1, q2, q3; // q1,2,3 = tap cac cau hoi level1 ,2,3
    // dan glam gio o day nua
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnNext;
    private javax.swing.JButton btnUser;
    private javax.swing.ButtonGroup btngrpQuestion;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JLabel lbl1;
    private javax.swing.JLabel lbl10;
    private javax.swing.JLabel lbl11;
    private javax.swing.JLabel lbl12;
    private javax.swing.JLabel lbl13;
    private javax.swing.JLabel lbl14;
    private javax.swing.JLabel lbl15;
    private javax.swing.JLabel lbl2;
    private javax.swing.JLabel lbl3;
    private javax.swing.JLabel lbl4;
    private javax.swing.JLabel lbl5;
    private javax.swing.JLabel lbl6;
    private javax.swing.JLabel lbl7;
    private javax.swing.JLabel lbl8;
    private javax.swing.JLabel lbl9;
    private javax.swing.JButton lblCall;
    private javax.swing.JButton lblHalf;
    private javax.swing.JLabel lblPlayerName;
    private javax.swing.JLabel lblQuestion;
    private javax.swing.JRadioButton rdbtnA;
    private javax.swing.JRadioButton rdbtnB;
    private javax.swing.JRadioButton rdbtnC;
    private javax.swing.JRadioButton rdbtnD;
    // End of variables declaration//GEN-END:variables
}
